package com.cn.sc.scitc;


import com.cn.sc.scitc.cyol.SCController;
import net.mamoe.mirai.console.plugin.jvm.JavaPlugin;
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescriptionBuilder;
import net.mamoe.mirai.event.GlobalEventChannel;
import net.mamoe.mirai.event.Listener;
import net.mamoe.mirai.event.events.MessageEvent;


public final class Plugin extends JavaPlugin {
    public static final Plugin INSTANCE = new Plugin();

    private Plugin() {
        super(new JvmPluginDescriptionBuilder("org.example.text.plugin", "1.0-SNAPSHOT")
                .name("启动程序")
                .info("启动成功发送私聊信息")
                .author("123")
                .build());
    }

    @Override
    public void onEnable() {
        getLogger().info("Plugin loaded!2333");

        Listener listener = GlobalEventChannel.INSTANCE.subscribeAlways(MessageEvent.class, g -> {
            RunPrefix(g.getMessage().contentToString(), g);
        });
    }

    private void RunPrefix(String input, MessageEvent a) {
        input = input.toLowerCase();

        if (input.startsWith("#查询")) {
            SCController sc = new SCController(input,String.valueOf(a.getSubject().getId()));
            a.getSubject().sendMessage(sc.getReMsg());
        }
    }
}